www.gusucode.com > 集团企业网站模板 html5生态企业类网站源码源码程序 > 集团企业网站模板 html5生态企业类网站源码源码程序/www1/style/js/plugins.js
// Generated by CoffeeScript 1.6.3 var __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; (function($) { var getScripts, getTouches, getVendor, isTouch, touchEvents, transitionEndEvent, vendor, vendorPrefix, _fn_plugin, _plugin; Math.region = Math.region || function(a, b, c) { return Math.min(c, Math.max(a, b)); }; getVendor = function() { var m, p, property; m = document.createElement("div"); property = { WebkitTransition: 'webkit', transition: '', MozTransition: 'moz', OTransition: 'o', msTransition: 'ms' }; for (p in property) { if (m.style[p] != null) { return property[p]; } } return null; }; getTouches = function(e) { var t; t = e.touches; if (t != null) { return { x: t[0].pageX, y: t[0].pageY }; } else { return { x: e.pageX, y: e.pageY }; } }; vendor = getVendor(); vendorPrefix = vendor === "" ? "" : "-" + vendor + "-"; isTouch = "ontouchstart" in window; transitionEndEvent = vendor === "" ? "transitionend" : vendor + "TransitionEnd"; touchEvents = isTouch != null ? { start: "touchstart", move: "touchmove", end: "touchend" } : { start: "mousedown", move: "mousemove", end: "mouseup" }; $._plugin_helper = { vendor: vendor, vendorPrefix: vendorPrefix, transformProp: vendorPrefix + "transform", transitionProp: vendorPrefix + "transition", hasTransition: vendorPrefix + "transform .5s", noTransition: "none", isTouch: isTouch, transitionEndEvent: transitionEndEvent, touchEvents: touchEvents, getTouches: getTouches, /* jQuery plugin wrapper $.namespace */ build: function(namespace, plugin) { $[namespace] = function(settings) { return new plugin(settings); }; $[namespace]["class"] = plugin; $[namespace].defaults = plugin.prototype.defaults; return $[namespace]; }, /* jQuery plugin wrapper $.fn.namespace */ buildFn: function(namespace, plugin) { $.fn[namespace] = function(settings) { var $dom, args, result; $dom = this; result = null; args = Array.prototype.slice.call(arguments, 1); $dom.each(function() { var $ele, pluginInst; $ele = $(this); pluginInst = $ele.data("plugin_" + namespace); if (typeof settings === "string") { return result = pluginInst[settings].apply(pluginInst, args); } else if (!(pluginInst != null)) { return new plugin($ele, settings); } }); if (result != null) { return result; } else { return $dom; } }; $.fn[namespace]["class"] = plugin; $.fn[namespace].defaults = plugin.prototype.defaults; return $.fn[namespace]; }, manipulateAttr: function(obj, key, value) { var keys, result; keys = key.split("."); result = obj; while (keys.length > 1 && (result != null)) { result = result[keys.unshift()]; } if (typeof value === "undefined") { return result[keys[0]]; } else if (value === null) { delete result[keys[0]]; } else { if (result != null) { return result[keys[0]] = value; } } } }; /* interface:plugin, base for all $ plugin classes */ _plugin = (function() { var namespace; namespace = "_plugin"; _plugin.prototype.namespace = namespace; function _plugin(settings) { this.settings = $.extend({}, this.defaults, settings); } _plugin.prototype.proxyTimeout = function(fun, delay) { return setTimeout(this._getProxyFun(fun), delay); }; _plugin.prototype.proxyInterval = function(fun, delay) { return setInterval(this._getProxyFun(fun), delay); }; _plugin.prototype._getProxyFun = function(fun) { if (typeof fun === "string") { fun = this[fun]; } return $.proxy(fun, this); }; $._plugin_helper.build(namespace, _plugin); return _plugin; })(); /* interface:plugin, base for all $.fn plugin classes */ _fn_plugin = (function(_super) { var namespace; __extends(_fn_plugin, _super); namespace = "_fn_plugin"; _fn_plugin.prototype.namespace = namespace; function _fn_plugin($ele, settings) { this.$ele = $ele; this.settings = $.extend({}, this.defaults, settings); $ele.data("plugin_" + this.namespace, this); } _fn_plugin.prototype.destroy = function() { this.$ele.removeData("plugin_" + this.namespace); this.$ele.off("." + this.namespace); }; _fn_plugin.prototype.proxyEvent = function() { var $dom, args, lastArg, listener; args = arguments; lastArg = args[args.length - 1]; if (($(lastArg)) === lastArg || lastArg instanceof $) { $dom = lastArg; listener = args[args.length - 2]; args = Array.prototype.slice.call(args, 0, args.length - 1); } else { $dom = this.$ele; listener = lastArg; } args[0] = (args[0].replace(/\s+/g, "." + this.namespace + " ")) + "." + this.namespace; args[args.length - 1] = this._getProxyFun(listener); $dom.on.apply($dom, args); }; _fn_plugin.prototype.unproxyEvent = function() { var $dom, args; args = arguments; $dom = args[1] || this.$ele; args[0] = (args[0].replace(/\s+/g, "." + this.namespace + " ")) + "." + this.namespace; $dom.off.call($dom, args[0]); }; $._plugin_helper.buildFn(namespace, _fn_plugin); return _fn_plugin; })($._plugin["class"]); getScripts = (function(_super) { var namespace; __extends(getScripts, _super); namespace = "getScripts"; getScripts.prototype.namespace = namespace; function getScripts() { getScripts.__super__.constructor.apply(this, arguments); this.scripts = this.settings.scripts; this.success = this.settings.success; this._getNext(); } getScripts.prototype._getNext = function() { if (this.scripts.length > 0) { $.getScript(this.scripts.shift(), $.proxy(arguments.callee, this)); } else { this.success && this.success(); } }; $._plugin_helper.build(namespace, getScripts); return getScripts; })(_plugin); })($); (function($) { var transit; transit = (function(_super) { var namespace, vendor, vendorPrefix; __extends(transit, _super); namespace = "transit"; vendor = $._plugin_helper.vendor; vendorPrefix = $._plugin_helper.vendorPrefix; transit.prototype.namespace = namespace; function transit() { var transitFun; transit.__super__.constructor.apply(this, arguments); this.$from = $(this.settings.from); this.$to = $(this.settings.to); transitFun = "hideShow"; if (this.settings.transEnabled) { if (vendor != null) { transitFun = "cssTransit"; } } this[transitFun](this.$from, this.$to); } transit.prototype.cssTransit = function($from, $to) { var allCls, delay, eventPage, hiddenCls, inCls, outCls, revert, timeoutDataKey, timeoutFrom, timeoutTo, transCls, transDur, transSettings; transSettings = this.settings; revert = transSettings.revert; inCls = revert ? transSettings.outCls : transSettings.inCls; outCls = revert ? transSettings.inCls : transSettings.outCls; transCls = transSettings.transCls; allCls = transCls + " " + inCls + " " + outCls; hiddenCls = transSettings.hiddenCls; delay = transSettings.delay; this._changeClass($to, outCls + " " + hiddenCls, transCls + " " + inCls + " "); this._changeClass($from, inCls, transCls); eventPage = $to.length > 0 ? $to : $from; transDur = (parseFloat(eventPage.css(vendorPrefix + "transition-duration"))) * 1000; timeoutDataKey = namespace + "-timeout"; timeoutFrom = $from.data(timeoutDataKey); timeoutTo = $to.data(timeoutDataKey); timeoutFrom && clearTimeout(timeoutFrom); timeoutTo && clearTimeout(timeoutTo); this.proxyTimeout(function() { $to.length > 0 && ($to.removeClass(inCls)).data(timeoutDataKey, this.proxyTimeout(function() { ($to.removeClass(allCls)).removeData(timeoutDataKey); this._transCallback(); }, transDur)); $from.length > 0 && ($from.addClass(outCls)).data(timeoutDataKey, this.proxyTimeout(function() { (($from.removeClass(allCls)).addClass(hiddenCls)).removeData(timeoutDataKey); if ($to.length === 0) { this._transCallback(); } }, transDur)); }, delay); }; transit.prototype.jqTransit = function($from, $to) { var animateComplete, fromParam, settings, toParam; settings = this.settings; animateComplete = $.proxy(this._transCallback(), this); fromParam = { duration: this.settings.jqDelay }; toParam = { duration: this.settings.jqDelay }; if ($from.length > 0) { fromParam.complete = animateComplete; } else { toParam.complete = animateComplete; } $from.stop(true).fadeOut(fromParam); $to.stop(true).fadeIn(toParam); }; transit.prototype.hideShow = function($from, $to) { var callback, hiddenCls; callback = this.settings.callback; hiddenCls = this.settings.hiddenCls; $to && $to.removeClass(hiddenCls); $from && $from.addClass(hiddenCls); this._transCallback(); }; transit.prototype._changeClass = function($ele, fromCls, toCls) { return ($ele.removeClass(fromCls)).addClass(toCls); }; transit.prototype._transCallback = function() { var callback; callback = this.settings.callback; return callback && callback.call(this, this.settings.from, this.settings.to); }; transit.prototype.defaults = { inCls: "in", outCls: "out", hiddenCls: "hidden", transCls: "fade", revert: false, callback: null, delay: 0, jqDelay: 500, transEnabled: true }; $._plugin_helper.build(namespace, transit); return transit; })($._plugin["class"]); })($); (function($) { /* scrolling slideshow, with interval switching */ var scrollflow; scrollflow = (function(_super) { var namespace; __extends(scrollflow, _super); namespace = "scrollflow"; scrollflow.prototype.namespace = namespace; function scrollflow() { var $nav; scrollflow.__super__.constructor.apply(this, arguments); this.$flow = this.$ele.children("ul"); this.$sliders = this.$flow.children("li"); this.len = this.$sliders.length; $nav = this.$ele.find(this.settings.nav); $nav.length > 0 && this._genNav($nav); this.prevButton = this.$ele.find(this.settings.prevButton); this.nextButton = this.$ele.find(this.settings.nextButton); this.prevButton.length > 0 && this.proxyEvent("click", "_prevclick", this.prevButton); this.nextButton.length > 0 && this.proxyEvent("click", "_nextclick", this.nextButton); this.proxyEvent("mouseenter", "_mouseenter"); this.proxyEvent("mouseleave", "_mouseleave"); this.run(); } /* init done and start slideshow */ scrollflow.prototype.run = function() { this.page(this.settings.page); this._intv = -1; return this.settings.interval > 0 && this.start(); }; scrollflow.prototype.destroy = function() { scrollflow.__super__.destroy.apply(this, arguments); this.stop(); this.prevButton.length > 0 && this.unproxyEvent("click", this.prevButton); this.nextButton.length > 0 && this.unproxyEvent("click", this.nextButton); return this.$navItems && this.unproxyEvent(this.settings.navAction, this.$navItems); }; /* switching page */ scrollflow.prototype.page = function(index) { var $to, left, next; next = this._getPageNum(index); if (next !== this.currPage) { $to = this.$sliders.eq(next); left = -$to.position().left + (this.$ele.width() - $to.width()) / 2; (this.$flow.stop(true)).animate({ left: left }, { duration: this.settings.delay }); this._setPage(next); } return this.currPage; }; scrollflow.prototype.prev = function(n) { return this.page(this.currPage - (n != null ? n : 1)); }; scrollflow.prototype.next = function(n) { return this.page(this.currPage + (n != null ? n : 1)); }; /* inteval slideshow */ scrollflow.prototype.start = function() { this.running = true; this._startInterval(); }; scrollflow.prototype.stop = function() { this.running = false; this._stopInterval(); }; scrollflow.prototype._startInterval = function() { this._intv < 0 && (this._intv = this.proxyInterval("_interval", this.settings.interval)); }; scrollflow.prototype._stopInterval = function() { clearInterval(this._intv); this._intv = -1; }; /* caculate the actaul page index */ scrollflow.prototype._getPageNum = function(index) { var next; if (index != null) { next = index; while (next < 0) { next += this.len; } return next % this.len; } else { return this.currPage; } }; /* generate the navs if exist */ scrollflow.prototype._genNav = function($nav) { var i, itemHtml, navHtml, _i, _ref; navHtml = ""; itemHtml = "<a></a>"; for (i = _i = 0, _ref = this.len; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { navHtml += itemHtml; } $nav.html(navHtml); this.$navItems = $nav.find("a"); this.proxyEvent(this.settings.navAction, "_navItemAction", this.$navItems); }; /* setup the nav and page state */ scrollflow.prototype._setPage = function(page) { var activeClass; activeClass = this.settings.activeClass; (this.$sliders.eq(this.currPage)).removeClass(activeClass); (this.$sliders.eq(page)).addClass(activeClass); if (this.$navItems != null) { (this.$navItems.eq(this.currPage)).removeClass(activeClass); (this.$navItems.eq(page)).addClass(activeClass); } this.currPage = page; this.$ele.trigger("page", page); }; /* events */ scrollflow.prototype._navItemAction = function(e) { this.page(($(e.currentTarget)).index()); }; scrollflow.prototype._prevclick = function(e) { this.prev(); }; scrollflow.prototype._nextclick = function(e) { this.next(); }; scrollflow.prototype._interval = function() { this.next(); }; scrollflow.prototype._mouseenter = function(e) { this._stopInterval(); }; scrollflow.prototype._mouseleave = function(e) { this.running && this._startInterval(); }; scrollflow.prototype.defaults = { page: 0, interval: 5000, nav: ".slider-nav", prevButton: ".slider-prev", nextButton: ".slider-next", navAction: "click", activeClass: "on", delay: 500 }; $._plugin_helper.buildFn(namespace, scrollflow); return scrollflow; })($.fn._fn_plugin["class"]); })($); (function($) { /* css transition slideshow, with jquery animation fallback */ var globalSectionScroller, sliderflow, _ref; sliderflow = (function(_super) { var namespace; __extends(sliderflow, _super); function sliderflow() { _ref = sliderflow.__super__.constructor.apply(this, arguments); return _ref; } namespace = "sliderflow"; sliderflow.prototype.namespace = namespace; sliderflow.prototype.run = function() { this.$sliders.addClass(this.settings.hiddenClass); return sliderflow.__super__.run.apply(this, arguments); }; sliderflow.prototype.page = function(index) { var $from, $to, next, transCls; next = this._getPageNum(index); if (next !== this.currPage) { transCls = this.settings.transCls; $from = this.$sliders.eq(this.currPage); $to = this.$sliders.eq(next); (this.$sliders.slice(Math.max(next - 1, 0), next + 2)).each(function() { var $item, background; $item = $(this); background = $item.attr("_background"); return background && ($item.css("background-image", "url(\"" + background + "\")")).removeAttr("_background"); }); this._setPage(next); $.transit({ from: $from, to: $to, transCls: transCls }); } return this.currPage; }; sliderflow.prototype.defaults = { page: 0, interval: 5000, nav: ".slider-nav", prevButton: ".slider-prev", nextButton: ".slider-next", navAction: "click", transCls: "fade", hiddenClass: "hidden", activeClass: "on" }; $._plugin_helper.buildFn(namespace, sliderflow); return sliderflow; })($.fn.scrollflow["class"]); /* section scroller, for thumb scrolling and so on */ globalSectionScroller = (function(_super) { var namespace; __extends(globalSectionScroller, _super); namespace = "sectionScroller"; globalSectionScroller.prototype.namespace = namespace; function globalSectionScroller() { globalSectionScroller.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.prevButtonSelector, "_prevclick"); this.proxyEvent("click", this.settings.nextButtonSelector, "_nextclick"); } globalSectionScroller.prototype._prevclick = function(e) { this.move(($(e.currentTarget)).siblings(this.settings.listSelector), -1); }; globalSectionScroller.prototype._nextclick = function(e) { this.move(($(e.currentTarget)).siblings(this.settings.listSelector), 1); }; globalSectionScroller.prototype.move = function($list, offset) { var $inner, $lis, $newPages, $pages, activeClass, allowLoop, lastLeft, left, len, listLeft, lw, page, w; $inner = $list.children(); $lis = $inner.children(); lastLeft = $lis.last().offset().left; listLeft = $list.offset().left; allowLoop = ($list.data("loop")) !== false; w = $list.width(); lw = $lis.width(); $pages = $lis.filter(function() { var _ref1; return (0 <= (_ref1 = ($(this)).offset().left - listLeft) && _ref1 <= w - lw); }); len = $lis.length - $pages.length + 1; page = $pages.first().index() + offset; if (allowLoop) { if (page < 0) { page += len; } else if (page >= len) { page = 0; } } if ((0 <= page && page < len)) { $newPages = $lis.slice(page, page + $pages.length); left = $newPages.first().position().left; activeClass = this.settings.activeClass; $newPages.addClass(activeClass); ($pages.not($newPages)).removeClass(activeClass); $inner.css({ left: -left }); } }; globalSectionScroller.prototype.defaults = { listSelector: ".role-list", prevButtonSelector: ".role-prev", nextButtonSelector: ".role-next", activeClass: "section-on" }; $._plugin_helper.buildFn(namespace, globalSectionScroller); return globalSectionScroller; })($.fn._fn_plugin["class"]); })($); /* plugin lazyloader */ (function($) { var lazyloader; lazyloader = (function(_super) { var namespace; __extends(lazyloader, _super); namespace = "lazyloader"; lazyloader.prototype.namespace = namespace; function lazyloader() { var settings; lazyloader.__super__.constructor.apply(this, arguments); settings = this.settings; this._isWindow = settings.window === window; this.$window = $(settings.window); this.$imgs = null; this._enabled = false; this._into = -1; this.refresh(); this.proxyEvent("scroll", "_scroll", this.$window); } lazyloader.prototype.destory = function() { lazyloader.__super__.destory.apply(this, arguments); this.unproxyEvent("scroll", this.$window); }; lazyloader.prototype.refresh = function() { this.$imgs = this.$ele.find("img[" + this.settings.srcAttr + "]"); this._refresh(); }; lazyloader.prototype._refresh = function() { var count, imgs, limit, settings, srcAttr, st, wh; settings = this.settings; limit = settings.limit; count = 0; srcAttr = settings.srcAttr; st = this._isWindow ? this.$window.scrollTop() : this.$window.offset().top; wh = this.$window.height(); imgs = []; this.$imgs = this.$imgs.filter(function() { var $img, h, y; $img = $(this); if (count < limit) { y = $img.offset().top; h = $img.height(); if (y + h > st && y < st + wh) { ($img.attr("src", $img.attr(srcAttr))).removeAttr(srcAttr); count++; false; } } return true; }); this._into = -1; }; /* events */ lazyloader.prototype._scroll = function(e) { this._into > 0 && clearTimeout(this._into); this._into = this.proxyTimeout("_refresh", this.settings.delay); }; lazyloader.prototype.defaults = { window: window, srcAttr: "_src", limit: 50, delay: 50 }; $._plugin_helper.buildFn(namespace, lazyloader); return lazyloader; })($.fn._fn_plugin["class"]); })($); (function($) { var linkfollower; linkfollower = (function(_super) { var namespace, vendor; __extends(linkfollower, _super); vendor = $._plugin_helper.vendor; namespace = "linkfollower"; linkfollower.prototype.namespace = namespace; function linkfollower() { var $on; linkfollower.__super__.constructor.apply(this, arguments); this.$follower = this.$ele.find(this.settings.followerSelector); this._active = null; $on = this.$ele.find(this.settings.activeClass); this.active($on.length > 0 ? $on.index : this.settings.active); this.proxyEvent("mouseenter", this.settings.linkSelector, "_linkmouseenter"); this.proxyEvent("mouseleave", "_mouseleave"); this.proxyEvent("click", this.settings.linkSelector, "_linkclick"); } /* set active link */ linkfollower.prototype.active = function(index) { (index != null) && this._follow(index, true); return this._active; }; linkfollower.prototype._follow = function(index, changeActive) { var $curr, $links, len; $links = this.$ele.find(this.settings.linkSelector); len = $links.length; if ((0 <= index && index < len)) { (this.$ele.find("." + this.settings.activeClass)).removeClass(this.settings.activeClass); $curr = ($links.eq(index)).addClass(this.settings.activeClass); if (vendor != null) { this.$follower.css({ top: $curr.position().top }); } else { this.$follower.stop().animate({ top: $curr.position().top }, "fast"); } if (changeActive) { this._active = index; this.$ele.trigger("change", index); } } }; /* events */ linkfollower.prototype._linkmouseenter = function(e) { this._follow(($(e.currentTarget)).index(), false); }; linkfollower.prototype._mouseleave = function(e) { this._follow(this._active, false); }; linkfollower.prototype._linkclick = function(e) { //hack .followerCon var $target = $(e.currentTarget), $targetPar = $target.parents('.followerCon'); if($targetPar.length > 0){ var $children = $targetPar.find(this.settings.linkSelector), index = 0; $children.each(function(itemIndex,ele){ if(ele == $target[0]){ index = itemIndex; } }); this.active(index); }else{ this.active(($(e.currentTarget)).index()); } }; linkfollower.prototype.defaults = { active: 0, linkSelector: "a", followerSelector: ".follower", activeClass: "on" }; $._plugin_helper.buildFn(namespace, linkfollower); return linkfollower; })($.fn._fn_plugin["class"]); })($); (function($) { var globalAcorr, globalBtnGroup, globalTab, preload; preload = function($div, callback) { var cache, src; src = $div.data("src"); cache = $div.data("cache"); if (src) { if (cache !== false) { ($div.removeAttr("data-src")).removeData("src"); } $div.load(src, function() { return callback && callback(); }); } else { callback && callback(); } }; globalBtnGroup = (function(_super) { var namespace; __extends(globalBtnGroup, _super); namespace = "globalBtnGroup"; globalBtnGroup.prototype.namespace = namespace; function globalBtnGroup() { globalBtnGroup.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.groupSelector + " a", "_btnclick"); } globalBtnGroup.prototype.switchTo = function($btn) { var $on, activeClass, index, last; activeClass = this.settings.activeClass; $on = $btn.siblings("." + activeClass); index = $btn.index(); last = $on.index(); if (!$btn.hasClass(activeClass)) { ($btn.addClass(activeClass)).prop("checked", true); last >= 0 && $on.removeClass(activeClass); } }; /* events */ globalBtnGroup.prototype._btnclick = function(e) { this.switchTo($(e.currentTarget)); }; globalBtnGroup.prototype.defaults = { groupSelector: ".role-btn-group", activeClass: "btn-on" }; $._plugin_helper.buildFn(namespace, globalBtnGroup); return globalBtnGroup; })($.fn._fn_plugin["class"]); globalTab = (function(_super) { var namespace; __extends(globalTab, _super); namespace = "globalTab"; globalTab.prototype.namespace = namespace; function globalTab() { globalTab.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.tabSelector + " a", "_tabclick"); } globalTab.prototype.switchTo = function($tab) { var $contents, $on, $parent, activeClass, contentsSelector, hiddenClass, index, last; activeClass = this.settings.activeClass; hiddenClass = this.settings.hiddenClass; $parent = $tab.closest(this.settings.tabSelector); contentsSelector = $parent.data("contents"); //hack by ppf var $linkCon = $tab.parents(".followerCon"); if($linkCon.length>0){ var $children = $linkCon.find('a'), index = 0; $children.each(function(itemIndex,ele){ var $ele = $(ele); if(ele == $tab[0]){ index = itemIndex; } var active = $ele.hasClass(activeClass); if(active){ $on = $ele; last = itemIndex } }); }else{ $on = $tab.siblings("." + activeClass); index = $tab.index(); last = $on.index(); } $contents = contentsSelector ? $(contentsSelector) : $parent.next().children(); if (!$tab.hasClass(activeClass)) { $tab.addClass(activeClass); if (last >= 0) { $on.removeClass(activeClass); ($contents.eq(last)).addClass(hiddenClass); } this._preload($contents.eq(index), function() { if ($tab.hasClass(activeClass)) { ($contents.eq(index)).removeClass(hiddenClass); } }); $parent.trigger("tabChange", index); } }; /* events */ globalTab.prototype._tabclick = function(e) { this.switchTo($(e.currentTarget)); }; globalTab.prototype._preload = preload; globalTab.prototype.defaults = { tabSelector: ".role-tabs", activeClass: "tab-on", hiddenClass: "hidden" }; $._plugin_helper.buildFn(namespace, globalTab); return globalTab; })($.fn._fn_plugin["class"]); globalAcorr = (function(_super) { var namespace, vendor; __extends(globalAcorr, _super); vendor = $._plugin_helper.vendor; namespace = "globalAcorr"; globalAcorr.prototype.namespace = namespace; function globalAcorr() { globalAcorr.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.acorrSelector + " " + this.settings.handleSelector, "_acorrclick"); } globalAcorr.prototype.switchTo = function($tab) { var $on, $parent, activeClass, index, last; activeClass = this.settings.activeClass; $parent = $tab.parent(); $on = $tab.siblings("." + activeClass); index = $tab.index(); last = $on.index(); if (!$tab.hasClass(activeClass)) { this._preload($tab, $.proxy(function() { var $content, $onContent, contentSelector, h; contentSelector = this.settings.contentSelector; $tab.addClass(activeClass); $content = $tab.children(contentSelector); h = $content.height(); $content.detach().css("height", 0); $tab.append($content); this.proxyTimeout(function() { $content.css("height", h); }); if (last >= 0) { $onContent = $on.children(contentSelector); if (!(vendor != null) || $onContent[0].style.height) { $on.removeClass(activeClass); $onContent.css("height", ""); } else { ($onContent.css("height", $onContent.height())).detach(); ($on.removeClass(activeClass)).append($onContent); this.proxyTimeout(function() { $onContent.css("height", ""); }, 0); } } }, this)); $parent.trigger("acorrChange", index); } }; /* events */ globalAcorr.prototype._acorrclick = function(e) { this.switchTo(($(e.currentTarget)).closest(this.settings.acorrSelector + ">")); }; globalAcorr.prototype._preload = preload; globalAcorr.prototype.defaults = { handleSelector: ".role-handle", contentSelector: ".acorr-content", acorrSelector: ".role-acorr", activeClass: "acorr-on" }; $._plugin_helper.buildFn(namespace, globalAcorr); return globalAcorr; })($.fn._fn_plugin["class"]); })($); (function($) { /* auto fix content when scrolling */ var lazyloader; lazyloader = (function(_super) { var namespace; __extends(lazyloader, _super); namespace = "autofixer"; $.support.positionFixed = (function() { var $div, hasFixed; $div = (($("<div></div>")).css({ position: "fixed", top: 100 })).prependTo("body"); hasFixed = $div.offset().top === 100; $div.remove(); return hasFixed; })(); lazyloader.prototype.namespace = namespace; function lazyloader() { var settings; lazyloader.__super__.constructor.apply(this, arguments); settings = this.settings; this.$window = $(settings.window); this.offset = this.$ele.offset(); this.height = this.$ele.height(); this.fixed = false; this.proxyEvent("scroll", "_scroll", this.$window); } lazyloader.prototype.destory = function() { lazyloader.__super__.destory.apply(this, arguments); this.unproxyEvent("scroll", this.$window); }; lazyloader.prototype._dofix = function() { var sb, st; st = this.$window.scrollTop(); sb = Math.max(($(document)).height() - st, 0); if (!this.fixed) { this.offset = this.$ele.offset(); this.height = this.$ele.height(); } if (st > this.offset.top && sb > this.height) { if (!this.fixed) { this.$ele.addClass(this.settings.fixedClass); this.fixed = true; } } else if (this.fixed) { this.$ele.removeClass(this.settings.fixedClass); this.fixed = false; } }; /* events */ lazyloader.prototype._scroll = function(e) { return this._dofix(); }; lazyloader.prototype.defaults = { window: window, fixedClass: "fixed" }; $._plugin_helper.buildFn(namespace, lazyloader); return lazyloader; })($.fn._fn_plugin["class"]); })($); (function($) { var globalPager; globalPager = (function(_super) { var namespace; __extends(globalPager, _super); namespace = "globalPager"; globalPager.prototype.namespace = namespace; function globalPager() { globalPager.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.pagerSelector + " a", "_pagerclick"); this.proxyEvent("click", "a[data-content]", "_pagerclick"); } /* events */ globalPager.prototype._pagerclick = function(e) { var $content, $target, contentSelector, href, loadingClass, st; $target = $(e.currentTarget); href = $target.attr("href"); contentSelector = ($target.data("content")) || (($target.closest(this.settings.pagerSelector)).data("content")); $content = $target.closest(contentSelector); loadingClass = this.settings.loadingClass; st = $content.offset().top; ($content.addClass(loadingClass)).load(href + " " + contentSelector + ">", function() { var $window; $window = $(window); ($content.removeClass(loadingClass)).trigger("loaded"); if ($window.scrollTop() > st) { $window.scrollTop(st); } }); e.preventDefault(); }; globalPager.prototype.defaults = { pagerSelector: ".role-pager", loadingClass: "loading" }; $._plugin_helper.buildFn(namespace, globalPager); return globalPager; })($.fn._fn_plugin["class"]); })($); (function($) { /* auto fix content when scrolling */ var scrollLoader; scrollLoader = (function(_super) { var namespace; __extends(scrollLoader, _super); namespace = "scrollLoader"; scrollLoader.prototype.namespace = namespace; function scrollLoader() { var settings; scrollLoader.__super__.constructor.apply(this, arguments); settings = this.settings; this.$window = $(settings.window); this._bottom = this._getBottom(); this._into = null; this._page = settings.page; this._url = settings.url || (this.$ele.data("url")) || window.location.href.replace(/(\?|&)?page=\d+(&)?/, function(s1, s2, s3) { if (s3 != null) { return s2; } else { return ""; } }); this.proxyEvent("scroll", "_scroll", this.$window); this._detect(); } scrollLoader.prototype.url = function(url) { if (url != null) { this._url = url; this._page = 0; this.$ele.empty(); this._load(); } else { return this._url; } }; scrollLoader.prototype.destory = function() { scrollLoader.__super__.destory.apply(this, arguments); this.unproxyEvent("scroll", this.$window); }; scrollLoader.prototype._getBottom = function() { return this.$ele.offset().top + this.$ele.height(); }; scrollLoader.prototype._detect = function() { var $window, sb; $window = this.$window; sb = $window.scrollTop() + $window.height(); if (sb >= this._bottom) { this._load(); } }; scrollLoader.prototype._load = function() { var $window, _this = this; $window = this.$window; this.unproxyEvent("scroll", $window); this.$ele.addClass(this.settings.loadingClass); return $.ajax({ url: this._url, data: { page: this._page + 1 }, dataType: "text", success: function(html) { var $html, $nextPage; $html = $(html); $nextPage = $html.find(_this.settings.selector + ">"); if ($nextPage.length === 0) { $nextPage = ($html.filter(_this.settings.selector)).children(); } if ($nextPage.length > 0) { _this.$ele.append($nextPage); _this._bottom = _this._getBottom(); _this._page++; _this.proxyEvent("scroll", "_scroll", $window); _this._into = _this.proxyTimeout("_detect", _this.settings.delay); } }, complete: function() { _this.$ele.removeClass(_this.settings.loadingClass); } }); }; /* events */ scrollLoader.prototype._scroll = function(e) { this._into && clearTimeout(this._into); this._into = this.proxyTimeout("_detect", this.settings.delay); }; scrollLoader.prototype.defaults = { window: window, delay: 100, page: 1, selector: ".role-waterfall", loadingClass: "loading", url: null }; $._plugin_helper.buildFn(namespace, scrollLoader); return scrollLoader; })($.fn._fn_plugin["class"]); })($); /* ui by JamesMozart */ (function($) { var dropdwonBox, globalCheck, globalCombo, globalDropDown, globalPopup, globalSelect, globalTooltip, globalValidator, wrapInput; globalValidator = (function(_super) { var namespace; __extends(globalValidator, _super); namespace = "globalValidator"; globalValidator.prototype.namespace = namespace; function globalValidator() { globalValidator.__super__.constructor.apply(this, arguments); this._into = null; this.template = this.settings.template; this.proxyEvent("focus", "input[data-validator],textarea[data-validator]", "_inputfocus"); this.proxyEvent("change", "select[data-validator]", "_inputchange"); this.proxyEvent("submit", "form", "_formsubmit"); } /* events */ globalValidator.prototype._inputchange = function(e) { var $input, _this = this; $input = $(e.currentTarget); clearTimeout(this._into); this._into = setTimeout(function() { _this._validate($input); }, this.settings.delay); }; globalValidator.prototype._inputfocus = function(e) { var $input, inputEvent; $input = $(e.currentTarget); if ($input.val() === "") { this._genMessage($input, "info"); } inputEvent = ($input.attr("type")) === "text" || ($input.prop("tagName")) === "TEXTAREA" ? "oninput" in window ? "input" : "keyup" : "change"; this.proxyEvent(inputEvent, "_inputchange", $input); this.proxyEvent("blur", "_inputblur", $input); }; globalValidator.prototype._inputblur = function(e) { var $input, inputEvent; $input = $(e.currentTarget); inputEvent = ($input.attr("type")) === "text" || ($input.prop("tagName")) === "TEXTAREA" ? "oninput" in window ? "input" : "keyup" : "change"; this.unproxyEvent(inputEvent, $input); this.unproxyEvent("blur", $input); }; globalValidator.prototype._formsubmit = function(e) { var $errors, $inputs, passed, _this = this; $inputs = ($(e.currentTarget)).find("[data-validator]"); $errors = $inputs.filter(function(i, input) { return !_this._validate($(input)); }); passed = $errors.length === 0; !passed && $errors.first().focus(); return passed; }; globalValidator.prototype._validate = function($input) { var passed, status, validator; validator = new RegExp($input.data("validator")); passed = validator.test($input.val()); status = passed ? "ok" : "error"; this._genMessage($input, status); return passed; }; globalValidator.prototype._genMessage = function($input, status) { var $messagebox, message; message = $input.data(status); while (($input.css("display")) === "none") { $input = $input.parent(); } $messagebox = $input.next(".messagebox"); if (!$messagebox.hasClass(status)) { ($input.next(".messagebox")).remove(); $input.after(this.template(message, status)); } }; globalValidator.prototype.defaults = { delay: 500, template: function(message, status) { return " <span class='messagebox " + status + "'>" + message + "</span>"; } }; $._plugin_helper.buildFn(namespace, globalValidator); return globalValidator; })($.fn._fn_plugin["class"]); globalCheck = (function(_super) { var namespace; __extends(globalCheck, _super); namespace = "globalCheck"; globalCheck.prototype.namespace = namespace; function globalCheck() { var checkSelector; globalCheck.__super__.constructor.apply(this, arguments); checkSelector = this.settings.checkSelector; this.proxyEvent("click", checkSelector, "_checkclick"); this.proxyEvent("change", checkSelector + " input", "_checkchange"); this.proxyEvent("click", "label", "_labelclick"); } /* events */ globalCheck.prototype._labelclick = function(e) { this._changeChecked(($(e.currentTarget)).find("input")); e.preventDefault(); }; globalCheck.prototype._checkclick = function(e) { var $btn, $input, activeClass; activeClass = this.settings.activeClass; $btn = $(e.currentTarget); $input = $btn.find("input"); if (($btn.hasClass("disabled")) || ($btn.closest("label")).length > 0) { return; } this._changeChecked($input); }; globalCheck.prototype._checkchange = function(e) { var $input, $radios, checked; $input = $(e.currentTarget); checked = $input.prop("checked"); this._setSpanChecked($input, checked); if (($input.attr("type")) === "radio") { $radios = (($input.closest("form")).find("[name='" + ($input.attr("name")) + "']")).not($input); this._setSpanChecked($radios, false); } else if (($input.closest(this.settings.checkAllSelector)).length > 0) { this._setChecked((($input.closest("form")).find("[name='" + ($input.attr("name")) + "']")).not($input), $input.prop("checked")); } }; globalCheck.prototype._changeChecked = function($input) { var checked; switch ($input.attr("type")) { case "radio": this._setChecked($input, true); break; case "checkbox": checked = $input.prop("checked"); this._setChecked($input, !checked); } }; globalCheck.prototype._setChecked = function($inputs, checked) { var _this = this; $inputs.each(function(i, input) { var $input; $input = $(input); if (checked !== $input.prop("checked")) { $input.prop("checked", checked); $input.trigger("change"); } }); }; globalCheck.prototype._setSpanChecked = function($input, checked) { ($input.closest(this.settings.checkSelector))[checked ? "addClass" : "removeClass"](this.settings.activeClass); }; globalCheck.prototype.defaults = { checkSelector: ".role-check", checkAllSelector: ".role-checkall", activeClass: "check-on" }; $._plugin_helper.buildFn(namespace, globalCheck); return globalCheck; })($.fn._fn_plugin["class"]); dropdwonBox = (function(_super) { var namespace; __extends(dropdwonBox, _super); namespace = "dropdwonBox"; dropdwonBox.prototype.namespace = namespace; function dropdwonBox() { dropdwonBox.__super__.constructor.apply(this, arguments); this.$selectUl = null; this.selectCallback = null; this.options = null; } dropdwonBox.prototype._liclicked = function(e) { var $li, option; if (this.selectCallback) { $li = $(e.currentTarget); option = this.options[$li.index()]; this.selectCallback.call(this, option.label, option.value); this.selectCallback = null; } }; dropdwonBox.prototype._genList = function($options, selectCallback) { var options; options = $options.map(function() { var $option; $option = $(this); return { label: $option.text(), value: $option.val(), active: $option.prop("selected"), disabled: ($option.attr("disabled")) === "disabled" }; }); return this._genListFromJSON(options, selectCallback); }; dropdwonBox.prototype._genListFromJSON = function(options, selectCallback) { var $selectUl, html; this.options = options; this.selectCallback = selectCallback; html = this.settings.template(options); if (this.$selectUl != null) { if (html) { $selectUl = this.$selectUl.html(($(html)).html()); } else { this._removeList(); } } else if (html) { this.$selectUl = $selectUl = ($(html)).prependTo("body"); this.proxyEvent("click", ">:not(.disabled)", "_liclicked", $selectUl); } return $selectUl; }; dropdwonBox.prototype._positionList = function($rel, addHeight, documentHeight) { var left, listH, offset, relH, splited, top, w; if (addHeight == null) { addHeight = false; } if (documentHeight == null) { documentHeight = ($(document)).height(); } offset = $rel.offset(); splited = $rel.hasClass("splited"); top = offset.top; left = splited ? $rel.prev().offset().left : offset.left; w = $rel.outerWidth(); relH = $rel.outerHeight(); listH = this.$selectUl.height(); if (top + listH < documentHeight) { if (addHeight) { top += relH; } } else { if (!addHeight) { top += relH; } top -= listH; } if (splited) { w += $rel.prev().outerWidth(); } this.$selectUl.css({ top: top, left: left, minWidth: w }); }; dropdwonBox.prototype._removeList = function() { if (this.$selectUl != null) { this.unproxyEvent("click", this.$selectUl); this.$selectUl.remove(); this.$selectUl = null; this.selectCallback = null; this.options = null; } }; dropdwonBox.prototype.template = function(options) { var html, option, _i, _len, _ref; if (options.length > 0) { html = "<ul class='dropdownbox scroll'>"; for (_i = 0, _len = options.length; _i < _len; _i++) { option = options[_i]; html += "<li" + (option.active ? " class='dropdownbox-on'" : option.disabled ? (option.label === (_ref = option.value) && _ref === "") ? " class='seperator'" : " class='disabled'" : "") + ">" + option.label + "</li>"; } return html + "</ul>"; } else { return ""; } }; $._plugin_helper.buildFn(namespace, dropdwonBox); return dropdwonBox; })($.fn._fn_plugin["class"]); globalSelect = (function(_super) { var namespace; __extends(globalSelect, _super); namespace = "globalSelect"; globalSelect.prototype.namespace = namespace; function globalSelect() { var selectSelector; globalSelect.__super__.constructor.apply(this, arguments); selectSelector = this.settings.selectSelector; this.selectClicked = false; this.proxyEvent("click", selectSelector, "_selectclick"); this.proxyEvent("change", selectSelector + " select", "_selectchange"); } /* events */ globalSelect.prototype._selectclick = function(e) { this._openSelectSpan($(e.currentTarget)); }; globalSelect.prototype._openSelectSpan = function($selectSpan) { var $options, $select, docEvent, offset, value, _this = this; $select = $selectSpan.find("select"); $options = $select.children(); value = $select.val(); if (($select.attr("disabled")) === "disabled") { return; } offset = $selectSpan.offset(); if (this.$selectUl) { this._removeList(); this.selectClicked = true; } else { docEvent = "click." + namespace + "dropdown"; ($(document)).on(docEvent, function() { if (!_this.selectClicked) { _this._removeList(); ($(document)).off(docEvent); } else { _this.selectClicked = false; } }); } this._genList($options, function(label, value) { if ($select.val() !== value) { $select.val(value); $select.trigger("change"); } setTimeout(function() { var nextSelector; nextSelector = $select.data("next"); if (nextSelector) { console.log(($(nextSelector)).closest(_this.settings.selectSelector)); return _this._openSelectSpan(($(nextSelector)).closest(_this.settings.selectSelector)); } }, 0); }); this._positionList($selectSpan, false); }; globalSelect.prototype._selectchange = function(e) { var $select, value; $select = $(e.currentTarget); value = $select.val(); this._setLabel($select, $select.children("[value='" + value + "']").text()); }; globalSelect.prototype._setLabel = function($select, label) { $select.prev().text(label); }; globalSelect.prototype.defaults = { selectSelector: ".role-select", template: globalSelect.prototype.template }; $._plugin_helper.buildFn(namespace, globalSelect); return globalSelect; })($.fn.dropdwonBox["class"]); globalCombo = (function(_super) { var namespace; __extends(globalCombo, _super); namespace = "globalCombo"; globalCombo.prototype.namespace = namespace; function globalCombo() { globalCombo.__super__.constructor.apply(this, arguments); this._into = null; this.inputEvent = "oninput" in window ? "input" : "keyup"; this.proxyEvent("focus", this.settings.comboSelector + " input", "_inputfocus"); } /* events */ globalCombo.prototype._inputfocus = function(e) { var $input; $input = $(e.currentTarget); this.proxyEvent(this.inputEvent, "_inputchange", $input); this.proxyEvent("blur", "_inputblur", $input); return this._search($input); }; globalCombo.prototype._inputchange = function(e) { var $input; $input = $(e.currentTarget); this._search($input); }; globalCombo.prototype._inputblur = function(e) { var $input, _this = this; $input = $(e.currentTarget); this.unproxyEvent(this.inputEvent, $input); this.unproxyEvent("blur", $input); setTimeout(function() { return _this._removeList(); }, this.settings.delay); }; globalCombo.prototype._search = function($input) { var $comboSpan, $options, $select, selectCallback, value; $comboSpan = $input.closest(this.settings.comboSelector); $select = $comboSpan.find("select"); value = $input.val(); $options = $select.children().filter(function() { var text; text = ($(this)).text(); return (text.indexOf(value)) > -1 && text !== value; }); if (($input.attr("disabled")) === "disabled") { return; } selectCallback = function(label, value) { $select.val(value); ($input.val(label)).focus().trigger(this.inputEvent); }; clearTimeout(this._into); this._into = this.proxyTimeout(function() { var documentHeight, source, _this = this; documentHeight = ($(document)).height(); if ((source = $comboSpan.data("source")) != null) { return $.ajax({ url: source.replace("{query}", encodeURIComponent(value)), dataType: "json", success: function(data) { if ($input.val() === value && _this._genListFromJSON(data, selectCallback)) { _this._positionList($input, true, documentHeight); } } }); } else if (this._genList($options, selectCallback)) { return this._positionList($input, true, documentHeight); } }, this.settings.delay); }; globalCombo.prototype.defaults = { comboSelector: ".role-combo", delay: 200, template: globalCombo.prototype.template }; $._plugin_helper.buildFn(namespace, globalCombo); return globalCombo; })($.fn.dropdwonBox["class"]); globalDropDown = (function(_super) { var namespace; __extends(globalDropDown, _super); namespace = "globalDropDown"; globalDropDown.prototype.namespace = namespace; function globalDropDown() { var dropdownSelector; globalDropDown.__super__.constructor.apply(this, arguments); this._into = null; dropdownSelector = this.settings.dropdownSelector; this.proxyEvent("click", dropdownSelector, "_btnclick"); } /* events */ globalDropDown.prototype._btnclick = function(e) { var $btn, $selectUl, docEvent, hiddenClass, _this = this; $btn = $(e.currentTarget); if ($btn.hasClass("disabled")) { return; } hiddenClass = this.settings.hiddenClass; $selectUl = $btn.next().removeClass(hiddenClass); if (this.$selectUl != null) { this.$selectUl.addClass(hiddenClass); this.dropdownClick = $selectUl[0] !== this.$selectUl[0]; } else { docEvent = "click." + namespace + "dropdown"; ($(document)).on(docEvent, function() { if (!_this.dropdownClick) { _this.$selectUl.addClass(hiddenClass); ($(document)).off(docEvent); _this.$selectUl = null; } else { _this.dropdownClick = false; } }); } this.$selectUl = $selectUl; this._positionList($btn, true); }; globalDropDown.prototype.defaults = { dropdownSelector: ".role-dropdown", dropdownboxSelector: ".role-dropdownbox", hiddenClass: "hidden", template: globalDropDown.prototype.template }; $._plugin_helper.buildFn(namespace, globalDropDown); return globalDropDown; })($.fn.dropdwonBox["class"]); globalPopup = (function(_super) { var namespace; __extends(globalPopup, _super); namespace = "globalPopup"; globalPopup.prototype.namespace = namespace; function globalPopup() { globalPopup.__super__.constructor.apply(this, arguments); this.proxyEvent("click", this.settings.btnSelector, "_btnclick"); } /* events */ globalPopup.prototype._btnclick = function(e) { var $btn; $btn = $(e.currentTarget); if (!$btn.hasClass("disabled")) { this.open($btn.attr("href"), $btn.data("modal")); } e.preventDefault(); }; globalPopup.prototype._closeclick = function(e) { if ((e.keyCode == null) || e.keyCode === 27) { this.close(); } }; globalPopup.prototype._initPopup = function($popup) { this.$popup = $popup; this.$popup.css({ marginLeft: -this.$popup.outerWidth() / 2 }); this.proxyEvent("click", "_closeclick", this.$modal); this.proxyEvent("click", this.settings.closeSelector, "_closeclick", this.$popup); this.proxyEvent("keydown", "_closeclick", $(document)); }; globalPopup.prototype.open = function(selector, showModal) { var $popup, $window, _this = this; if (this.$popup) { this.close(); } $popup = $(selector); $window = $(window); showModal && (this.$modal = $("<div class='modal'/>").appendTo("body")); if ($popup.length > 0) { this.$popup = $popup.removeClass(this.settings.hiddenClass); this._initPopup($popup.removeClass(this.settings.hiddenClass)); } else { $.ajax({ url: selector, dataType: "html", success: function(html) { _this._initPopup(($(html)).appendTo("body")); } }); } }; globalPopup.prototype.close = function() { this.unproxyEvent("click", this.$popup); this.unproxyEvent("click", this.$modal); this.unproxyEvent("keydown", $(document)); this.$modal && this.$modal.remove(); if (!this.$popup.attr("id")) { this.$popup.remove(); } else { this.$popup.addClass(this.settings.hiddenClass); } this.$popup = this.$modal = null; }; globalPopup.prototype.defaults = { popupSelector: ".role-popup", btnSelector: ".role-popupbtn", closeSelector: ".role-close", hiddenClass: "hidden" }; $._plugin_helper.buildFn(namespace, globalPopup); return globalPopup; })($.fn._fn_plugin["class"]); globalTooltip = (function(_super) { var namespace; __extends(globalTooltip, _super); namespace = "globalTooltip"; globalTooltip.prototype.namespace = namespace; function globalTooltip() { var e; globalTooltip.__super__.constructor.apply(this, arguments); try { $(":hover"); this.$tooltip = null; this._enable(); } catch (_error) { e = _error; } } globalTooltip.prototype.destroy = function() { clearTimeout(this._intv); }; /* events */ globalTooltip.prototype._hover = function() { var $hover, offset, pos, tooltip; $hover = ($("[data-tooltip]:hover")).last(); if ($hover.length > 0) { tooltip = $hover.data("tooltip"); offset = $hover.offset(); pos = { top: offset.top + $hover.outerHeight(), left: offset.left }; if (!this.$tooltip) { this.$tooltip = $(this.settings.template(tooltip)); (this.$tooltip.css(pos)).appendTo("body"); } else { this.$tooltip.html(tooltip); this.$tooltip.css(pos); return; } } else if (this.$tooltip) { this.$tooltip.remove(); this.$tooltip = null; } }; globalTooltip.prototype._enable = function() { this._intv = this.proxyInterval("_hover", this.settings.delay); }; globalTooltip.prototype.defaults = { delay: 1000, template: function(tooltip) { return "<div class='tooltipbox'>" + tooltip + "</div>"; } }; $._plugin_helper.buildFn(namespace, globalTooltip); return globalTooltip; })($.fn._fn_plugin["class"]); wrapInput = function($inputs, spanClass) { var activeClass, disabledClass; if (spanClass == null) { spanClass = ""; } activeClass = "check-on"; disabledClass = "disabled"; return $inputs.each(function() { var $input, className, prefix; $input = $(this); prefix = $input.data("prefix"); className = this.className + " " + spanClass; if ($input.prop("checked")) { className += " " + activeClass; } if ($input.attr("disabled")) { className += " " + disabledClass; } $input.wrap("<span class='" + className + "'/>"); prefix && $input.before(prefix); this.className = ""; }); }; return $.wrapUI = function($ele) { if ($ele == null) { $ele = document; } $ele = $($ele); (wrapInput($ele.find(".role-select"))).each(function() { var $select; $select = $(this); $select.before("<span>" + $select.children("[value='" + $select.val() + "']").text() + "</span>"); }); wrapInput($ele.find(".checkbox,.radiobox,.checkbtn")); return $ele; }; })($); (function($) { /* global plugins init script */ $.initComponents = function(config) { var $content, components, item, params, _i, _len; $content = $("#content"); components = { hashreload: function(defaultHash) { ($(window)).on("hashchange", function() { var hash; hash = window.location.hash || defaultHash; return $("[href='" + hash + "']").trigger("click"); }).trigger("hashchange"); }, autofixer: function() { $.support.positionFixed && ($(".autofix")).autofixer(); }, slider: function() { var $navItem; $navItem = (($("#slider")).sliderflow({ interval: 5000 })).find(".slider-nav a"); ($("head")).append("<style>.slider .slider-nav a{width:" + 100 / $navItem.length + "%;}</style>"); }, tab: function() { $content.globalTab(); }, acorr: function() { $content.globalAcorr(); }, pager: function() { $content.globalPager(); }, scroller: function() { ($(document)).sectionScroller(); }, colorbox: function() { var $imgDiv, defaults, initGallery; defaults = { fixed: $.support.positionFixed, scrolling: false, maxWidth: "100%", maxHeight: "95%", slideshow: true, slideshowAuto: false }; initGallery = function() { var $galery, $uls; $galery = $(".gallery"); $uls = $galery.closest("[id]"); if ($uls.length > 0) { $uls.each(function() { (($(this)).find(".gallery")).colorbox({ rel: "#" + (($(this)).attr("id")) + " gallery" }); }); } else { ($(".gallery")).colorbox({ rel: "gallery" }); } }; if (!$.support.positionFixed) { ($(document)).on("cbox_open", function() { ($("input,select,textarea")).addClass("novis"); ($(this)).on("mousewheel.colorbox", false); ($("#cboxOverlay")).height(($(this)).height()); }).on("cbox_closed", function() { ($("input,select,textarea")).removeClass("novis"); ($(this)).off("mousewheel.colorbox"); }); } $.colorbox.showGroup = function(rels, title, index) { var html, rel, _i, _len; if (index == null) { index = 0; } if (!this.$imgDiv) { this.$imgDiv = ($("<div class='hidden'/>")).appendTo("body"); } html = ""; for (_i = 0, _len = rels.length; _i < _len; _i++) { rel = rels[_i]; html += "<a class='dummy-gallery' href='" + rel + "'/>"; } ((this.$imgDiv.html(html)).children().colorbox({ rel: "dummy-gallery" }).eq(index)).trigger("click"); }; $.extend($.colorbox.settings, defaults); $imgDiv = ($("<div class='hidden'/>")).appendTo("body"); initGallery(); (($(document)).on("click", "a", function(e) { var $a, group, href, index, isFrame, settings, title; $a = $(this); href = $a.data("href"); group = $a.data("group"); title = $a.attr("title"); if (href) { isFrame = $a.data("iframe"); settings = { href: href }; if (isFrame) { $.extend(settings, { iframe: isFrame, width: ($a.data("width")) || 960, height: ($a.data("height")) || 600 }); } $.colorbox(settings); } else if (group) { index = $a.data("index"); $.colorbox.showGroup(group.split(","), title, index); } })).on("loaded", function(e) { initGallery(); }); }, linkfollower: function() { var $nav; $nav = $("#abouts_tabs"); $nav.linkfollower().on("tabChange", function() { var nt, st; st = Math.min(($(window)).scrollTop()); nt = $content.offset().top; if (st > nt) { ($(window)).scrollTop(nt); } }); }, lazyloader: function() { $content.lazyloader(); }, scrollloader: function() { var selector; selector = ".role-waterfall"; ($content.find(selector)).scrollLoader({ selector: selector }); } }; for (_i = 0, _len = config.length; _i < _len; _i++) { item = config[_i]; params = item.split(":"); components[params[0]] && components[params[0]].apply($, params.slice(1)); } }; /* auto init once dom loaded */ ($(document)).ready(function() { var componentsStr; componentsStr = ($("body")).data("components"); if (componentsStr) { $.initComponents(componentsStr.split(",")); } if (!$.support.positionFixed) { ($("#navmenu li")).on("mouseenter", function() { (($(this)).children("div")).show(); }).on("mouseleave", function() { (($(this)).children("div")).hide(); }); } ($("#share_wechat")).on("click", function(e) { var $a, $dropdown, isOn; $a = $(this); isOn = $a.hasClass("on"); $a.addClass("on"); if (!isOn) { $dropdown = ($(this)).prev().removeClass("hidden"); setTimeout(function() { ($(document)).one("click", function(e) { $a.removeClass("on"); $dropdown.addClass("hidden"); }); }); } }); }); })($);